var app = new Vue({
	el: "#app",
	data: {
		title: "会员卡",
		Language: {},
		content: {
			result: {
				info: {
					name: ""
				}
			}
		}
	},
	methods: {
		Langes: function(v) {
			$.ajax({
				type: "get",
				dataType: "json",
				url: "../Langue/" + v + ".json",
				success: function(h) {
					app.Language = h;
				},
				error: function(e) {
					console.log("错误");
				}
			});
		},
		cont: function() {
			let data = {};
			data.id = sessionStorage.getItem("member_card_id");
			common_ajax("get_card_info", data, "zh", function(h) {
				if(h.result.info) { //防止没有数据时出现报错
					app.content = h;
				}
				//会员卡的背景以及颜色
				if(h.result.info.color) {
					$("#card").css("background", h.result.info.color);
				} else {
					$("#card").css("backgroundImage", "https://foodievc.oss-ap-southeast-1.aliyuncs.com/"+h.result.info.thumb);
				}
				//渲染二维码
				codes(h.result.info.sn);
			});
		}
	},
})
//首次加载语言
if(localStorage.getItem("lanuage")) {
	app.Langes(localStorage.getItem("lanuage"));
} else {
	app.Langes("en");
}
app.cont();
$("#succeed-card .content>button").click(function() {
	$("#Payment").hide();
	$("#succeed-card").hide();
	$("#Card").show();
})
$("#code").click(function(){
	if($(this).is('.sel')){
		$("section").show();
		$(this).removeClass("sel");
	}else{
		$("section").hide();
		$(this).addClass("sel");
	}
})
//二维码生成
function codes(txt) {
	$("#cod").qrcode({
		render: "canvas", //canvas方式
		width: 100, //宽度
		height: 100, //高度
		text: txt //任意内容
	});
}